<?php
if ($__s_textarea_impl == 'layui') {
    //layui提供的编辑器
    ?>
    <textarea id="<?php echo $__s_textarea_id; ?>" class="<?php echo $__s_textarea_class; ?>"
              name="<?php echo $__s_textarea_name; ?>"
              impl="<?php echo $__s_textarea_impl; ?>"
              style="display: none;"><?php echo $__s_textarea_value; ?></textarea>
    <script>
        layui.use('layedit', function () {
            var layedit = layui.layedit;
            var options = <?php echo json_encode($__s_textarea_options); ?>;
            options.uploadImage = {};
            options.uploadImage.url = "/core/file/upload?responseType=layedit";
            options.uploadImage.type = 'post';
            var textareaIdx = layedit.build('<?php echo $__s_textarea_id; ?>', options);
            $("#<?php echo $__s_textarea_id; ?>").attr("idx", textareaIdx);
        });
    </script>
    <?php
    if (!isset($_S_TEXTAREA_GLOBAL_INCLUDED)) {
        $_S_TEXTAREA_GLOBAL_INCLUDED = true;
        ?>
        <script>
            g.textarea = {
                getContent: function (id) {
                    var textareaIdx = $("#" + id).attr("idx");
                    return layui.layedit.getContent(textareaIdx);
                },
                setContent: function (id, content, append) {
                    var textareaIdx = $("#" + id).attr("idx");
                    layui.layedit.setContent(textareaIdx, content, append);
                }
            };
        </script>
        <?php
    }
    ?>
    <?php
} else {
    ?>

    <?php
}
?>
